<!DOCTYPE html>
<html>
<head>
	<title>3-5 计算属性的 getter 和 setter</title>
	<script type="text/javascript" src="../../vue.js"></script>
</head>
<body>
	<div id='root'>
		{{fullName}}
		{{age}}
	</div>
	<script type="text/javascript">
		var vm = new Vue({
			el:'#root',
			data:{
				firstName:'Yao',
				lastName:'Ming',
				age:39
			},
			computed:{
				fullName:{
					//获取值
					get:function(){
						console.log('执行get');
						return this.firstName + ' ' + this.lastName
					},
					//设置值
					set:function(value){
						console.log('set---' + value);
						//将字符串转化为数组
						var arr = value.split(' ');
						this.firstName = arr[0];
						this.lastName = arr[1];
					}
				}
			}

		});
	</script>
</body>
</html>